<template>
  <div class="search">
    <van-nav-bar
  title="详情页"
  left-text="返回"
  right-text="..."
  left-arrow
  @click-left="$router.go(-1)"/>

   <van-search
                    v-model="searchkey"
                  shape="round"
                   show-action
                  background="#4fc08d"
                  placeholder="输入商家信息"
                   @search="onSearch"
                >
                 <template #action>
    <div @click="onSearch">搜索</div>
  </template>
                </van-search>
     <div @click="$router.push({path:'/detail',query:{id:item.mtWmPoiId} })" class="shop" v-for="(item,index) in list" :key="index">
        <div class="img-box">
          <img :src="item.picUrl" alt="">
        </div>
        <div class="text">
          <div>{{item.shopName}}</div>
          <div>{{item.monthSalesTip}}</div>
          <div>{{item.minPriceTip}}</div>
        </div>
      </div>
  </div>
</template>

<script>
import { shop_search } from "../utils/api";
export default {
    data(){
        return{
            searchkey:'',
            list:[]
        }
    },
    methods:{
        onSearch(){
            console.log(this.searchkey);
            if(this.searchkey){
                shop_search({searchkey:this.searchkey}).then((res)=>{
                    this.list=res.data.list
                })
            }else{
                this.list=[]
            }
        }
    }
}
</script>

<style lang="scss" scoped>
.shop{
  display: flex;
  margin: 10px;
  .img-box{
    width: 100px;
    margin-right: 10px;
    img{
      width: 100%;
    }
  }
  .text{
    flex:1;
  }
}
</style>